package org.lanqiao.tools;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class BaseServlet
 */
@WebServlet("/BaseServlet")
public class BaseServlet extends HttpServlet {
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected ResponseData redata = new ResponseData();
	// 判断用户传递的参数是否为空
	public boolean isNull(String key) {
		
		if (request.getParameter(key) == null) {
			return true;
		}else if (request.getParameter(key) == "") {
			return true;
		}
		return false;
	}

	// 获取用户传递过来的整形
	public Integer getInt(String key) {
		if (!isNull(key))
			return Integer.parseInt(request.getParameter(key));
		redata.setMsg(key+":null");
		return null;
	}

	// 获取用户传递过来的字符串
	public String getString(String key) {
		if (!isNull(key))
			return request.getParameter(key);
		redata.setMsg(key+":null");
		return null;
	}
}
